cmake_minimum_required(VERSION 3.22)
project(Sofa.Component.SolidMechanics.FEM LANGUAGES CXX)

set(SOFACOMPONENTSOLIDMECHANICSFEM_SOURCE_DIR "src/sofa/component/solidmechanics/fem")

set(OFACOMPONENTSOLIDMECHANICSFEM_DIRS Elastic HyperElastic NonUniform)
foreach(fem_dir ${OFACOMPONENTSOLIDMECHANICSFEM_DIRS})
    sofa_add_subdirectory(module ${fem_dir} ${PROJECT_NAME}.${fem_dir} ON)
    if(TARGET ${PROJECT_NAME}.${fem_dir})
        list(APPEND SOFACOMPONENTSOLIDMECHANICSFEM_TARGETS ${PROJECT_NAME}.${fem_dir})
    endif()
endforeach()

set(HEADER_FILES
    ${SOFACOMPONENTSOLIDMECHANICSFEM_SOURCE_DIR}/config.h.in
    ${SOFACOMPONENTSOLIDMECHANICSFEM_SOURCE_DIR}/init.h
)

set(SOURCE_FILES
    ${SOFACOMPONENTSOLIDMECHANICSFEM_SOURCE_DIR}/init.cpp
)

add_library(${PROJECT_NAME} SHARED ${HEADER_FILES} ${SOURCE_FILES})
target_link_libraries(${PROJECT_NAME} PUBLIC ${SOFACOMPONENTSOLIDMECHANICSFEM_TARGETS})

sofa_create_package_with_targets(
    PACKAGE_NAME ${PROJECT_NAME}
    PACKAGE_VERSION ${Sofa_VERSION}
    TARGETS ${PROJECT_NAME} AUTO_SET_TARGET_PROPERTIES
    INCLUDE_SOURCE_DIR "src"
    INCLUDE_INSTALL_DIR "${PROJECT_NAME}"
)
